package main

import (
	"../server/app/controller/serverCheck"
	"../server/app/model"
	"../server/common"
	"github.com/gogf/gf/g"
	"github.com/gogf/gf/g/net/ghttp"
	"github.com/gogf/gf/g/os/glog"
)

func init() {
	//
	runPath:=common.GetCurrentDirectory()//程序执行目录
	_ = g.Config().SetPath(runPath + "/configs")
	v := g.View()
	c := g.Config()
	s := g.Server()
	// 配置对象及视图对象配置
	_ = c.AddPath(runPath + "/configs")
	_ = v.AddPath(runPath + "/template")
	v.SetDelimiters("${", "}")
	/*初始化orm*/
	//g.Config().SetFileName("config.toml")
	//model.Db =g.DB("live_code");
	model.Db =g.DB();
	model.DbCompany =g.DB();
	// glog配置
	logpath := c.GetString("setting.logpath")
	glog.SetPath(logpath)
	glog.SetStdoutPrint(true)
	// Web Server配置
	s.SetServerRoot(runPath+"/public")
	s.SetLogPath(logpath)
	s.SetNameToUriType(ghttp.NAME_TO_URI_TYPE_ALLLOWER)
	s.SetErrorLogEnabled(true)
	s.SetAccessLogEnabled(true)
	s.SetPort(8299)
	// 路由配置
	ss := g.Server()
	// 某些浏览器直接请求favicon.ico文件，特别是产生404时
	ss.SetRewrite("/favicon.ico", "/resource/image/favicon.ico")
	ss.BindController("/servicecheck", new(serverCheck.Controller))

}

func main()  {
	_ = g.Server().Run()
}